
import ICapability from 'components/capability/interfaces/ICapability';
import { Element } from 'components/Three';
import * as THREE from 'three';
import Controller from 'Controller';
import React from 'react';

/** 平行光 */
export const directionalLight: ICapability<undefined> = {
    id: 'directionalLight',
    title: '平行光',
    useExpand: () => {

        const onClick = React.useCallback(() => {
            const threeController = Controller.instance.state.threeController;
            const light = new THREE.DirectionalLight(0xffffff, 0.5);


            // const d = 50;

            // light.shadow.camera.left = - d;
            // light.shadow.camera.right = d;
            // light.shadow.camera.top = d;
            // light.shadow.camera.bottom = - d;

            light.shadow.camera.far = 1000;
            light.shadow.bias = - 0.0001;

            const element = new Element('light', light.uuid, light);
            Controller.instance.state.threeController.sceneAdd(element);
            threeController.run(async s => s.selectedElementUuid = element.uuid);
        }, [])

        return {
            onClick,
        }
    }
}